import { Injectable, Injector } from '@angular/core';
import { Constant, ServiceResult } from '@core/constant';
import {_HttpClient, SettingsService} from '@delon/theme';
import { MyHttpClient } from '../MyHttpClient';

@Injectable()
export class fileService {
  get cnt(): Constant {
    return this.injector.get(Constant);
  }

  constructor(
    private injector: Injector,
    private http: _HttpClient,
    private myHttp: MyHttpClient,
    public setting: SettingsService,

  ) {}

  /**
   * 分页获取商品
   */
  list(): string {
    return `${this.cnt.baseUrl}/rest/fxjFileMainController/list/`+this.setting.user.username;
  }  
  /**
   * 借阅列表
   */
  list1(): string {
    return `${this.cnt.baseUrl}/rest/fxjdqData04Controller/list/`+this.setting.user.username;
  }
  /**
   * 上传图片
   */
  uploadUrl() {
    return `${this.cnt.baseUrl}/rest/base/uploadfile`;
  }
  delfile(productId) {
    return this.http.get(
      `${this.cnt.baseUrl}/rest/base/delfile/${productId}`,
    );
  }
  /**
   * 添加商品
   * @param prods
   */
  addfile(fileobj) {
    return this.http.post(
      `${this.cnt.baseUrl}/rest/fxjFileMainController`,
      fileobj,
    );
  }
    /**
   * 添加借阅
   * @param prods
   */
  addfile1(fileobj) {
    return this.http.post(
      `${this.cnt.baseUrl}/rest/fxjdqData04Controller`,
      fileobj,
    );
  }

  /**
   * 修改商品
   * @param product
   */
  editfile(fileobj) {
    return this.http.put(
      `${this.cnt.baseUrl}/rest/fxjFileMainController/${fileobj.id}`,
      fileobj,
    );
  }
  editfile1(fileobj) {
    return this.http.put(
      `${this.cnt.baseUrl}/rest/fxjdqData04Controller/${fileobj.id}`,
      fileobj,
    );
  }

  getfile(fileobjid) {
    return this.http.get(
      `${this.cnt.baseUrl}/rest/fxjFileMainController/${fileobjid}`,
    );
  }
  getfile1(fileobjid) {
    return this.http.get(
      `${this.cnt.baseUrl}/rest/fxjdqData04Controller/${fileobjid}`,
    );
  }

}
